<?php
$this->Html->css('chat', null, array('inline' => false));
$this->Html->script('chat', array('inline' => false));
?>
<div style="float: left; width: 250px;">
	<h3>People online:</h3>
	<ul>
		<?php
		foreach ($users as $user):
				echo '<li><a href="javascript:void(0)" onclick="chatWith(\''.$user['name'].'\', \''.$user['id_user'].'\')">'.$user['name'].' '.$user['surname'].'</a></li>';
		endforeach; ?>
	</ul>
</div>
<div style="float: left; width: 500px;">
	<div id="create_post">
		<?php
			echo $this -> Form -> create('Post', array('action' => 'add'));
			echo $this -> Form -> input('text', array('label' => 'What\'s in your mind?'));
			echo $this -> Form -> select('scope', array(
				array(
					'0' => 'University',
					$user_logged['id_faculty'] => $user_logged['name_faculty']
				)
			), array('empty' => false)
			);
			echo $this -> Form -> end('main/shout.png');
		?>
	</div>

	<br /><br />

	<select id='faculty'>
		<?php if($isAdmin) echo "<option value='-1'>All</option>"; ?>
		<option value='0'>University</option>
		<?php
		if($isAdmin) {
			foreach ($faculties as $faculty) {
				echo "<option value='" . $faculty['Faculty']['id_faculty'] . "'>" . $faculty['Faculty']['name'] . "</option>";
			}
		} else {
			echo "<option value='".$user_logged['id_faculty']."'>".$user_logged['name_faculty']."</option>";
		}
		?>
	</select>

	<br /><br /><br />

	<div id="post_list" style="width: 70%; margin: 0 auto; ">
	
		<?php
		echo "<hr><br>";
		foreach ($posts as $post) {
			echo "<div class='post' name=" . (is_null($post['Faculty']['id_faculty']) ? "0" : $post['Faculty']['id_faculty']) . ">";
			echo "<div id='post_user' style='float:left; text-align=right'>" . $this -> Html -> link($post['User']['name'] . " " . $post['User']['surname'], array('controller' => 'users', 'action' => 'profile', $post['User']['id_user'])) . "</div>";
			echo "<div id='post_faculty' style='float:right; text-align=right'> " . (is_null($post['Faculty']['id_faculty']) ? "University" : $post['Faculty']['name']) . "</div><br><br>";
			echo "<div id='post_text' style='clear:both; text-align:left'>" . $post['Post']['text'] . "</div><br>";
			echo "<div id='post_text' style='text-align:right'>" . $post['Post']['created'] . "</div><br><br><hr>";
			echo "</div><br />";
		}
		?>
		
	</div>
</div>
